<template>
  <view class="content">
    <van-nav-bar title="支付完成" left-text="" :left-arrow="true" placeholder fixed @click-left="onClickLeft" />
    <view
      class="order"
      :style="{
        height: 'calc(100vh - 132rpx - ' + safeAreaTop + 'px)',
      }"
    >
      <view class="order-cont">
        <view class="order-sucess">
          <image class="img-box" src="https://images.tongzhuangkc.com/tz/finish.png" alt="" />
          <text>支付成功</text>
        </view>
        <view class="bill-btn" @click="goPage">查看账单</view>
      </view>
      <view class="link">
        <image class="img-box" :src="info.wx_kefu_qrcode" alt="" />
        <view class="link-name">客服微信号</view>
        <view class="link-code">{{ info.kefu_wx_code }}</view>
        <view class="link-copy" @click="copyHandle">复制</view>
        <view class="link-title">专属客服</view>
        <view class="link-des"
          >添加专属客服，为您提供更多服务 <br />-代运营服务 <br />-推广涨粉 <br />-免费好货推广机会</view
        >
      </view>
    </view>
  </view>
</template>

<script>
import { reactive, toRefs } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { useUserStore } from '@/store/modules/user'
export default {
  components: {},
  setup() {
    const state = reactive({
      safeAreaTop: 0,
      info: {},
    })
    const copyHandle = () => {
      uni.setClipboardData({
        data: state.info.kefu_wx_code,
        success: function () {
          uni.showToast({
            title: '复制成功',
            icon: 'none',
          })
        },
        fail: function () {
          console.log(888)
        },
      })
    }
    const goPage = () => {
      uni.navigateTo({
        url: `/subpackage-user/expense/index`,
      })
    }
    const onClickLeft = () => {
      uni.navigateBack({
        delta: 1,
      })
    }
    onShow(() => {
      state.info = useUserStore().getField()
      uni.getSystemInfo({
        success: function (res) {
          state.safeAreaTop = res.safeAreaInsets.top === 20 ? 0 : res.safeAreaInsets.top
        },
      })
    })
    return {
      ...toRefs(state),
      copyHandle,
      goPage,
      onClickLeft,
    }
  },
}
</script>

<style lang="scss">
.content {
  height: 100vh;
  background: #fff;
}
.order {
  height: calc(100vh - 230rpx);
  overflow-y: auto;
}
.order-cont {
  margin: 80rpx 64rpx 44rpx;
  text-align: center;

  .order-sucess {
    font-size: 32rpx;

    .img-box {
      width: 128rpx;
      height: 128rpx;
    }
    text {
      display: block;
      margin: 16px 0 32rpx;
      color: #2b303b;
    }
  }
  .bill-btn {
    margin: 0 auto;
    width: 251rpx;
    height: 84rpx;
    background: #edf3ff;
    border-radius: 40rpx;
    color: #3775f2;
    line-height: 84rpx;
    text-align: center;
  }
}
.link {
  text-align: center;
  margin: 0 64rpx 80rpx;
  border: 8rpx solid #ebf2ff;
  padding: 50rpx 0 40rpx;
  .img-box {
    width: 304rpx;
    height: 304rpx;
  }
  .link-name {
    font-size: 24rpx;
    margin: 34rpx 0 8rpx;
    line-height: 32rpx;
  }
  .link-code {
    height: 64rpx;
    font-size: 48rpx;
    font-weight: 500;
    color: #2b303b;
    line-height: 64rpx;
  }
  .link-copy {
    width: 144rpx;
    height: 56rpx;
    font-size: 24rpx;
    color: #fff;
    text-align: center;
    line-height: 56rpx;
    background: #3775f2;
    border-radius: 40rpx;
    margin: 8rpx auto 24rpx;
  }
  .link-title {
    font-size: 32rpx;
    font-weight: 500;
    color: #2b303b;
    line-height: 48rpx;
  }
  .link-des {
    font-size: 28rpx;
    font-weight: 400;
    color: #555b66;
    line-height: 40rpx;
  }
}
</style>
